package com.svse.designPattern.structure.flyweight.test;

import com.svse.designPattern.structure.flyweight.flyweight.Flyweight;
import com.svse.designPattern.structure.flyweight.flyweightfactory.FlyweightFactory;
import com.svse.designPattern.structure.flyweight.unsharableflyweight.UnsharedConcreteFlyweight;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/8/2 9:26
 */
public class FlyweightPattern {
    public static void main(String[] args) {
        FlyweightFactory factory=new FlyweightFactory();

        Flyweight f01=factory.getFlyweight("a");
        Flyweight f02=factory.getFlyweight("a");
        Flyweight f03=factory.getFlyweight("a");
        Flyweight f11=factory.getFlyweight("b");
        Flyweight f12=factory.getFlyweight("b");
        f01.operation(new UnsharedConcreteFlyweight("第1次调用a。"));
        f02.operation(new UnsharedConcreteFlyweight("第2次调用a。"));
        f03.operation(new UnsharedConcreteFlyweight("第3次调用a。"));
        f11.operation(new UnsharedConcreteFlyweight("第1次调用b。"));
        f12.operation(new UnsharedConcreteFlyweight("第2次调用b。"));
    }
}
